package lesson2.com.biz;


import java.util.Comparator;


public class CustomerCreditLimitComparator implements Comparator<Customer>{

    @Override
    //public int compare(Object o1, Object o2) {
     public int compare(Customer first, Customer second) {
       // if(!(o1 instanceof Customer)
       //         || !(o2 instanceof Customer)){
       //     throw new IllegalArgumentException("Can only compare Customers");
       // }
       // Customer first = (Customer)o1;
       // Customer second = (Customer)o2;
        double crLimit1 = first.getCreditLimit();
        double crLimit2 = second.getCreditLimit();
        if(crLimit1==crLimit2){
            return 0;
        }
        if(crLimit1<crLimit2){
            return -1;
        }
        return 1;
    }

}
